#include "Animation.h"
#include <time.h>
#include "imageManager.h"
Animation::Animation()
{
}

Animation::Animation(int x, int y, int count, int delay)
	:m_x(x)
	, m_y(y)
	, m_count(count)
	, m_delay(delay)
{

}

void Animation::update()
{

	if (m_startTime == 0)
	{
		m_startTime = clock();
	}
	m_index = ((clock() - m_startTime) / m_delay) % m_count;

	if (m_index == m_count - 1)
	{
		m_finished = true;
	}
}

void Animation::render()
{
	imageManager::drawImg(m_x, m_y, imageManager::getInstaance()->getImage(std::to_string(m_index)));
}


